<?php
/*
 * Author:  Somnath Shinde- soma.shinde@gmail.com Mobile No:- 9423792564
 * 
 * Create Date: 
 * 
 * Version of MYSQL_to_PHP: 1.1
 * 
 * Ranzani( YZ'S );
 * 
 */
//require_once 'classes/DataBaseMysql.class.php';

Class BaseLabInvestingReports {

	protected $m_intId;
	protected $m_intPatientId;
	protected $m_intDoctorId;
	protected $m_strDocumentAttachmentPath;
	protected $m_intDocumentAttachmentId;
	protected $connection;

	public function  __construct() {
		if( true == isset( $_SERVER['connection'] ) ) {
			$this->connection = $_SERVER['connection'];
		}
	}

	
	/*******************************************************************************************
	******************************** get Functions *********************************************
	*******************************************************************************************/

	public function getId(){
		return $this->m_intId;
	}

	public function getPatientId(){
		return $this->m_intPatientId;
	}

	public function getDoctorId(){
		return $this->m_intDoctorId;
	}

	public function getDocumentAttachmentPath(){
		return $this->m_strDocumentAttachmentPath;
	}

	public function getDocumentAttachmentId(){
		return $this->m_intDocumentAttachmentId;
	}
	
	/*******************************************************************************************
	********************************* set Functions ********************************************
	*******************************************************************************************/

	public function setId( $Id ){
		$this->m_intId = $Id;
	}

	public function setPatientId( $PatientId ){
		$this->m_intPatientId = $PatientId;
	}

	public function setDoctorId( $DoctorId ){
		$this->m_intDoctorId = $DoctorId;
	}

	public function setDocumentAttachmentPath( $DocumentAttachmentPath ){
		$this->m_strDocumentAttachmentPath = $DocumentAttachmentPath;
	}

	public function setDocumentAttachmentId( $DocumentAttachmentId ){
		$this->m_intDocumentAttachmentId = $DocumentAttachmentId;
	}
	
	/*******************************************************************************************
	********************************* Insert Functions ********************************************
	*******************************************************************************************/

	public function insert(){
		return $this->connection->RunQuery( "Insert into LAB_INVESTING_REPORTS (patient_id, doctor_id, document_attachment_path, document_attachment_id) values (" . $this->getPatientId() . ", " . $this->getDoctorId() . ", '" . $this->getDocumentAttachmentPath() . "', " . $this->getDocumentAttachmentId() . ")");
	}
	
	/*******************************************************************************************
	********************************* Update Functions ********************************************
	*******************************************************************************************/

	public function update(){
		return $this->connection->RunQuery( "UPDATE LAB_INVESTING_REPORTS set  patient_id= " . $this->getPatientId() . ", doctor_id= " . $this->getDoctorId() . ", document_attachment_path= '" . $this->getDocumentAttachmentPath() . "', document_attachment_id= " . $this->getDocumentAttachmentId() . " where id =" . $this->getId() );
	}
	
	/*******************************************************************************************
	********************************* Delete Functions ********************************************
	*******************************************************************************************/

	public function Delete($intId ) {
		$this->connection->RunQuery( "DELETE FROM lab_investing_reports WHERE id = $intId");
	}

	public function fetchNextId() {
		$result = $this->connection->RunQuery( "SELECT AUTO_INCREMENT as id FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = 'lab_investing_reports'" );
		if( false == $result ) return NULL;

		while( $row = $result->fetch_array( MYSQLI_ASSOC ) ) {
			$this->id = $row["id"];
		}

		return $this->id;
	}

}